{% extends 'core/base.html' %}

{% block content %}
<div class="home-container">
    <div class="hero-section">
        <h2>欢迎使用垃圾分类平台</h2>
        <p class="hero-text">保护环境，从正确分类垃圾开始。输入垃圾名称，快速查询它属于哪一类。</p>

        <div class="search-box">
            <form method="get" action="{% url 'search' %}">
                <div class="search-input-group">
                    <input type="text" name="q" placeholder="例如：电池、果皮、纸巾…" required>
                    <button type="submit" class="search-btn">开始查询</button>
                </div>
            </form>
        </div>
    </div>

    <div class="features-section">
        <h3>平台功能：</h3>
        <div class="feature-cards">
            <div class="feature-card">
                <div class="feature-icon">🔍</div>
                <h4>垃圾分类快速查询</h4>
                <p>快速准确地查询各类垃圾的分类方式</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon">🧾</div>
                <h4>我的查询记录</h4>
                <p>记录您的查询历史，方便下次快速查找</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon">📚</div>
                <h4>垃圾分类小知识</h4>
                <p>了解更多关于垃圾分类的知识和技巧</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon">📥</div>
                <h4>用户反馈与建议</h4>
                <p>帮助我们改进平台，提供更好的服务</p>
            </div>
        </div>
    </div>

    {% if not user.is_authenticated %}
    <div class="cta-section">
        <p>更多功能等你体验</p>
        <div class="cta-buttons">
            <a href="{% url 'login' %}" class="btn">登录</a>
            <a href="{% url 'register' %}" class="btn btn-secondary">注册</a>
        </div>
    </div>
    {% endif %}
</div>

<style>
    .home-container {
        max-width: 900px;
        margin: 0 auto;
    }

    .hero-section {
        text-align: center;
        padding: 2rem 1rem 3rem;
        background-color: #e8f5e9;
        border-radius: 10px;
        margin-bottom: 2rem;
    }

    .hero-text {
        font-size: 1.2rem;
        max-width: 700px;
        margin: 1rem auto 2rem;
        color: #4a4a4a;
    }

    .search-box {
        max-width: 600px;
        margin: 0 auto;
    }

    .search-input-group {
        display: flex;
        box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        border-radius: 50px;
        overflow: hidden;
    }

    .search-input-group input {
        flex: 1;
        border: none;
        padding: 15px 25px;
        font-size: 1.1rem;
        border-radius: 50px 0 0 50px;
    }

    .search-input-group input:focus {
        outline: none;
    }

    .search-btn {
        padding: 15px 30px;
        border-radius: 0 50px 50px 0;
        font-size: 1.1rem;
        background-color: var(--primary);
    }

    .features-section {
        margin: 3rem 0;
    }

    .feature-cards {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
        margin-top: 1.5rem;
    }

    .feature-card {
        background-color: white;
        border-radius: 8px;
        padding: 1.5rem;
        text-align: center;
        box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        transition: transform 0.3s;
    }

    .feature-card:hover {
        transform: translateY(-5px);
    }

    .feature-icon {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }

    .feature-card h4 {
        color: var(--primary-dark);
        margin-bottom: 0.5rem;
    }

    .cta-section {
        text-align: center;
        background-color: #e3f2fd;
        padding: 2rem;
        border-radius: 10px;
        margin: 2rem 0;
    }

    .cta-section p {
        font-size: 1.2rem;
        margin-bottom: 1.5rem;
    }

    .cta-buttons {
        display: flex;
        justify-content: center;
        gap: 20px;
    }

    .cta-buttons .btn {
        padding: 10px 30px;
        font-size: 1.1rem;
    }

    @media (max-width: 768px) {
        .search-input-group {
            flex-direction: column;
            box-shadow: none;
        }

        .search-input-group input {
            border-radius: 50px;
            margin-bottom: 10px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        }

        .search-btn {
            border-radius: 50px;
        }

        .feature-cards {
            grid-template-columns: 1fr;
        }

        .cta-buttons {
            flex-direction: column;
            gap: 10px;
        }
    }
</style>
{% endblock %}